package cn.itcast.jx.util;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

public class JSONUtils {
	public static void writeJson(String str) {
		HttpServletResponse response = ServletActionContext.getResponse();
		//设置字符集编码和数据格式
		response.setContentType("application/json;charset=UTF-8");
		response.setHeader("cache-control", "no-cache");
		//写
		try {
			response.getWriter().write(str);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
